package com.cdut.logistics.model.dao.datacentre;

import java.util.Date;
import com.cdut.logistics.model.entity.datacentre.BaseDict;
import com.jfinal.plugin.activerecord.Db;

/**  
 * @ClassName: Area 
 * @Description: 操作数据库 
 * @author wxt.asus
 * @date 2018年1月26日 上午9:13:52    
 */
public class Dict extends BaseDict<Dict>{
	public static Dict dao = new Dict();
	private static final long serialVersionUID = 1L;
	public String baseSql = " and is_use = 1";
	public String sql1 = "SELECT * FROM sys_dict WHERE id = ?"+baseSql;
	public String sql2 = "UPDATE sys_dict set description =?, updated=? where id =?"+ baseSql;
	public String sql4 = "select * from sys_dict where label like ?"+ baseSql;
	public String sql3 = "UPDATE sys_dict set is_use =?, updated=? where id =?"+ baseSql;
	public String sql5 = "SELECT * FROM sys_dict WHERE type = ?"+baseSql;
	public String sql6 = "SELECT * FROM sys_dict WHERE description like ?"+baseSql;
	/**  
	 * @Title: save  
	 * @Description: 新增维修类型
	 * @author wxt.xia
	 * @param dept
	 * @throws  
	 */
	public void save(Dict dict) {
		dict.set("created", new Date());
		dict.set("updated", new Date());
		dict.set("is_use", 1);
		dict.set("active", 1);
		System.out.println(dict.toString());
		dict.save();
	}
	
	/**  
	 * @Title: remove  
	 * @Description: 删除维修类型
	 * @author wxt.xia
	 * @param id
	 * @throws  
	 */
	public void remove(int id) {
		Db.update(sql3,0,new Date(),id);
	}

	/**  
	 * @Title: queryById  
	 * @Description: 根据字典值id查询字典值记录
	 * @author wxt.xia
	 * @param id
	 * @return
	 * @throws  
	 */
	public Dict queryById(int id) {
		return findById(id);
	}
}
